package com.ucode.tool.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * 节点基类
 * @date: 2020年5月4日 下午2:58:32
 */
@SuppressWarnings("serial")
public class BaseNode implements INode {
    /**
     * 节点Id
     */
    protected Long id;
    /**
     * 父节点Id
     */
    protected Long parentId;
    /**
     *  子孙节点
     */
    protected List<INode> children;
    
    @Override
    public Long getId() {
        return this.id;
    }

    @Override
    public Long getParentId() {
        return this.parentId;
    }

    @Override
    public List<INode> getChildren() {
        return this.children;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public void setChildren(List<INode> children) {
        this.children = children;
    }

    @Override
    public void addChildren(INode node) {
        if(this.children == null)
            this.children = new ArrayList<INode>();
        this.children.add(node);
    }

}
